/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.railway.utils;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Kenny
 */
public class FareTableModel extends AbstractTableModel {

    private ArrayList<String> columnHeader;
    private ArrayList<ArrayList<Object>> rowData;

    public FareTableModel(ArrayList<String> columnHeader, ArrayList<ArrayList<Object>> rowData) {
        this.columnHeader = columnHeader;
        this.rowData = rowData;
    }

    @Override
    public int getRowCount() {
        return rowData.size();
    }

    @Override
    public String getColumnName(int col) {
        return columnHeader.get(col);
    }

    @Override
    public int getColumnCount() {
        return columnHeader.size();
    }

    @Override
    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return rowData.get(rowIndex).get(columnIndex);
    }

    @Override
    public boolean isCellEditable(int row, int col) {
        if (col == 2) {
            return true;
        } else {
            return false;
        }
    }
}
